/*
 * Authentification.java
 *
 * Created on 2  2007 0:15
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.persistent.entity;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * Entity class Authentification
 * 
 * 
 * @author alexog
 */
@Entity
@Table(name = "authentification")
@NamedQueries( {
        @NamedQuery(name = "Authentification.findById", query = "SELECT a FROM Authentification a WHERE a.id = :id"),
        @NamedQuery(name = "Authentification.findByPassword", query = "SELECT a FROM Authentification a WHERE a.password = :password"),
        @NamedQuery(name = "Authentification.findByAuthtype", query = "SELECT a FROM Authentification a WHERE a.authtype = :authtype"),
        @NamedQuery(name = "Authentification.findByUsername", query = "SELECT a FROM Authentification a WHERE a.username = :username"),
        @NamedQuery(name = "Authentification.findByRolename", query = "SELECT a FROM Authentification a WHERE a.rolename = :rolename")
    })
public class Authentification implements Serializable {

    @Id
    @Column(name = "ID", nullable = false)
    @GeneratedValue()
    private Integer id;

    @Column(name = "password")
    private String password;

    @Column(name = "authtype")
    private String authtype;

    @Column(name = "username")
    private String username;

    @Column(name = "rolename")
    private String rolename;

    @OneToOne
    @JoinColumn(name="ACCOUNT_ID")
    private Account account;
    
    /**
     * Creates a new instance of Authentification
     */
    public Authentification() {
    }

    /**
     * Creates a new instance of Authentification with the specified values.
     * 
     * @param id the id of the Authentification
     */
    public Authentification(Integer id) {
        this.id = id;
    }

    /**
     * Gets the id of this Authentification.
     * 
     * @return the id
     */
    public Integer getId() {
        return this.id;
    }

    /**
     * Sets the id of this Authentification to the specified value.
     * 
     * @param id the new id
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * Gets the password of this Authentification.
     * 
     * @return the password
     */
    public String getPassword() {
        return this.password;
    }

    /**
     * Sets the password of this Authentification to the specified value.
     * 
     * @param password the new password
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * Gets the authtype of this Authentification.
     * 
     * @return the authtype
     */
    public String getAuthtype() {
        return this.authtype;
    }

    /**
     * Sets the authtype of this Authentification to the specified value.
     * 
     * @param authtype the new authtype
     */
    public void setAuthtype(String authtype) {
        this.authtype = authtype;
    }

    /**
     * Gets the username of this Authentification.
     * 
     * @return the username
     */
    public String getUsername() {
        return this.username;
    }

    /**
     * Sets the username of this Authentification to the specified value.
     * 
     * @param username the new username
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * Gets the rolename of this Authentification.
     * 
     * @return the rolename
     */
    public String getRolename() {
        return this.rolename;
    }

    /**
     * Sets the rolename of this Authentification to the specified value.
     * 
     * @param rolename the new rolename
     */
    public void setRolename(String rolename) {
        this.rolename = rolename;
    }

    /**
     * Gets the accountId of this Authentification.
     * 
     * @return the accountId
     */
    public Account getAccount() {
        return this.account;
    }

    /**
     * Sets the accountId of this Authentification to the specified value.
     * 
     * @param accountId the new accountId
     */
    public void setAccount(Account account) {
        this.account = account;
    }

    /**
     * Returns a hash code value for the object.  This implementation computes 
     * a hash code value based on the id fields in this object.
     * @return a hash code value for this object.
     */
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    /**
     * Determines whether another object is equal to this Authentification.  The result is 
     * <code>true</code> if and only if the argument is not null and is a Authentification object that 
     * has the same id field values as this object.
     * 
     * @param object the reference object with which to compare
     * @return <code>true</code> if this object is the same as the argument;
     * <code>false</code> otherwise.
     */
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Authentification)) {
            return false;
        }
        Authentification other = (Authentification)object;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) return false;
        return true;
    }

    /**
     * Returns a string representation of the object.  This implementation constructs 
     * that representation based on the id fields.
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return "com.persistent.entity.Authentification[id=" + id + "]";
    }
    
}
